Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. 如何解决与 qgrapics 相关的类在图片非常巨大(30000*40000)时无法完全显示内容的问题
Forum Updated to NodeBB v4.3 + New Features

如何解决与 qgrapics 相关的类在图片非常巨大(30000*40000)时无法完全显示内容的问题

Scheduled Pinned Locked Moved Solved Chinese
1 Posts 1 Posters 603 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    HereV
    wrote on last edited by
    #1

    我的问题是: 为了显示巨型图片 (30000x40000), 我使用了与 qgraphicsscene相关的类和方法。但在成功加载数据并显示后,我发现显示的内容只是部分,场景底部有一个黑色区域,这表明程序没有成功显示图片的内容。在代码中,我使用 qgraphsitemgroup 来保存图像,这是因为 QGraphicsPixmapItem 可能无法保存如此大量的数据,因此我将图像分成几部分。我猜想这也许是所涉及的类存在一些限制, 或者使用的方法是否是错误的?所以我想问,是否有任何相关的方法来打破这个限制,或者是否有其他方法来描绘这样一个巨大的图像。

    void PicView::addImage(const QImage& image, int row, int col)
          {
          map = new QGraphicsPixmapItem(QPixmap::fromImage(image));
              map->setPos(row, col);
              imgGroup->addToGroup(map);
              m_bottom = image.height() + col;
              m_right = image.width() + row;
              scene->setSceneRect(imgGroup->sceneBoundingRect());
          }
      
          PicTileWidget::PicTileWidget()
          {
          scene = new QGraphicsScene();
          view = new PicView(scene);
          view->setBackgroundBrush(QBrush(Qt::red, Qt::SolidPattern));
          QHBoxLayout* layout = new QHBoxLayout();
          setLayout(layout);
          layout->addWidget(view);
          ...//code for reading data
          for (auto i = 0; i < colamount; i++)
              for (auto j = 0; j < rowamount; j++)
              {
                  int x = j * dc + delt_x, y = i * dr + delt_y;
                  cv::Mat subimg;
                  std::cout << "ceilimg number:" << i * colamount + j << "\nceilimg pos:"  \
                      << x << " " << y << " " << dc << " " << dr << std::endl;
                  srcimg(cv::Rect(x, y, dc, dr)).copyTo(subimg);
                  QImage QsubImage = QImage((const unsigned char*)(subimg.data), subimg.cols, subimg.rows, QImage::Format_RGB888);
      
                  view->addImage(QsubImage, j * QsubImage.width(), i * QsubImage.height());
              }
         }
    
    

    ![alt text](d1cd9bec-2731-46f3-bfec-cf8e469f99c7-image.png image url)
    子图像约为 3072 x 3840,可以清楚地看到下部显示不完整。

    谢谢!

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved